package com.yq.day30;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author 3307235355@qq.com
 * @description 追赶特性
 * @since 2022/06/30 15:05
 */
public class Demo06 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        long currentTime = System.currentTimeMillis();
        long planTime = currentTime - 20000;

        //    调度
        //     timer.schedule(new MyTask2(),new Date(planTime),2000);
        timer.scheduleAtFixedRate(new MyTask2(), new Date(planTime), 2000);
    }
}

class MyTask2 extends TimerTask {

    @Override
    public void run() {
        long start = System.currentTimeMillis();
        long end = System.currentTimeMillis();
        System.out.println("start = " + start);
        System.out.println("end = " + end);
    }
}